package cn.cvs.config;

import cn.cvs.inteceptor.LoginInteceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Auther: zwt
 * @Date: 2021/12/14 - 12 - 14 - 8:47
 * @Description: cn.cvs.config
 * @version: 1.0
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration interceptorRegistration = registry.addInterceptor(new LoginInteceptor());
        //拦截所有请求
        interceptorRegistration.addPathPatterns("/**");
        //在上面的基础上，放过下面的请求
        interceptorRegistration.excludePathPatterns("/","/toLogin","/login");
        //放过静态资源
        interceptorRegistration.excludePathPatterns("/statics/**");
    }
}
